package com.xyd.servlet;

import com.xyd.entity.User;
import com.xyd.service.UserService;
import com.xyd.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 类描述：
 *根据ID删除用户
 * @author 赵瑞硕
 * @date 2021/1/12 19:31
 */

@WebServlet("/userdeleteVisit")
public class UserdeleteVisitServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UserService userService=new UserServiceImpl();
        String euUserId=request.getParameter("euUserId");
        User mcvList=userService.queryUser(euUserId);
        System.out.println(mcvList.getEuStatus());
        if (mcvList.getEuStatus()!=2){
            int t=userService.deleteVisitUser(euUserId);
            if (t==1){
                request.getRequestDispatcher("userVisitServlet").forward(request,response);
            }
            else {
                request.getRequestDispatcher("userVisitServlet").forward(request,response);
            }
        }
        else {
            response.sendRedirect("userVisitServlet?deas=yes");
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
